package com.qinhailin.portal.business.ctrl;

import com.jfinal.aop.Inject;
import com.jfinal.core.Path;
import com.jfinal.plugin.activerecord.Record;

import com.qinhailin.common.base.BaseController;
import com.qinhailin.common.vo.Grid;
import com.qinhailin.portal.business.model.IDeviceInfo;
import com.qinhailin.portal.business.service.IDeviceInfoService;
import org.codehaus.jackson.node.ObjectNode;

/**
 * 
 * @author qinhailin
 * @date 2024-12-12
 */
@Path("/portal/business/iDeviceInfo")
public class IDeviceInfoController extends BaseController {

    @Inject
    IDeviceInfoService service;

  	public void index(){
    	render("index.html");
  	}

    public void list(){
        Record record = getAllParamsToRecord();
        record.remove("pageSize","pageNumber");
        renderJson(service.queryForList(getParaToInt("pageNumber",1), getParaToInt("pageSize",10),record));
    }

    public void list2(){
        Record record = getAllParamsToRecord();
        Object devideid = record.get("devideid");
        if(devideid == null){
            record.set("devideid",createUUID());
        }
        record.remove("pageS8ize","pageNumber");
        renderJson(service.queryForList(getParaToInt("pageNumber",1), getParaToInt("pageSize",10),record));
    }

    public void add() {
    	render("add.html");
    }

    public void save() {
        IDeviceInfo entity=getBean(IDeviceInfo.class);
    	entity.save();
    	setAttr("iDeviceInfo", entity);
    	render("add.html");
    }

    public void edit() {
        setAttr("iDeviceInfo", service.findById(getPara(0)));
        render("edit.html");
    }

    public void update() {
        IDeviceInfo entity=getBean(IDeviceInfo.class);
        entity.update();
        setAttr("iDeviceInfo", entity);
        render("edit.html");
    }

    public void delete() {
        service.deleteByIds(getIds());
        renderJson(suc());
    }
    public void  querydevice(){
        Record record = getAllParamsToRecord();
        Object devideid = record.get("devideid");
        // 查询满足条件的数据
        ObjectNode deviceInfo = service.getDeviceInfo(devideid+"");
        renderJson(deviceInfo.toString());
    }
}
